<!DOCTYPE html>
<html>
<head>
<#include "../include/include.ftl"/>
<meta charset="utf-8">
<title>修改缴纳单位表单</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<script type="text/javascript">
	layui.use('form', function() {
		var form = layui.form;
		form.on('submit(add)', function(data) {
			layerAjax('${basePath}/api/unit/modify/', data.field, 'unitList');
			return false;
		})
	});

	$(document).ready(
			function() {
				var Flag = $("#optionValue").val();
				if (Flag == 1) {
					$("#optionId option[value='" + Flag + "']").attr(
							"selected", "selected");
				} else if (Flag == 2) {
					$("#optionId option[value='" + Flag + "']").attr(
							"selected", "selected");
				}
			});

	function inputOnBlur() {
		var nameValue = $("#name").val();
		var id = $("#id").val();
		$.ajax({
			url : "${basePath}/paymentUnit/validate-unit-name",
			type : 'post',
			data : {
				"name" : nameValue,
				"id" : id
			},
			traditional : true,
			success : function(d) {
				if (d.code == 12) {
					layer.msg('用户名已存在！', {
						icon : 5
					});
					$("input[name=name]").focus();
				}
			},
			error : function(e) {
				layer.alert("发生错误", {
					icon : 6
				}, function() {
					var index = parent.layer.getFrameIndex(window.name);
					parent.layer.close(index);
				});
			}
		});
		return false;
	}
	function clearForm(oForm) {
		var els = oForm.elements;
		for (var i = 0; i < els.length; i++) {
			els[i].value = "";
		}
		return false;
	}
</script>
</head>

<body>
	<form class="layui-form" style="margin-top: 50px">
		<input type="hidden" name="id" value="${payUnit.id }" id="id" /> <input
			type="hidden" name="status" value="${payUnit.status}" /> <input
			id="optionValue" type="hidden" class="span2" value="${payUnit.type}">
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label"><span style="color: black;">单位名称:</span><span
					style="color: red;"> *</span></label>
				<div class="layui-input-inline">
					<input type="text" name="name" class="layui-input" id="name"
						style="border: 0 lay-verify=" required" value="${payUnit.name}"
						onBlur="inputOnBlur()">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label">单位类型:</label>
				<div class="layui-input-inline">
					<select name="type" lay-search id="optionId"
						class="easyui-validatebox span2">
						<option>请选择</option>
						<option value="1">学校</option>
						<option value="2">物业</option>
					</select>
				</div>
			</div>
		</div>

		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label"><span style="color: black;">对公账号:</span><span
					style="color: red;"> *</span></label>
				<div class="layui-input-inline">
					<input type="text" name=corporateAccount class="layui-input"
						lay-verify="required" value="${payUnit.corporateAccount}">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label">负责人:</label>
				<div class="layui-input-inline">
					<input type="text" name="principal" class="layui-input"
						value="${payUnit.principal}" lay-verify="required">
				</div>
			</div>
		</div>

		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label"><span style="color: black;">联系电话:</span><span
					style="color: red;"> *</span></label>
				<div class="layui-input-inline">
					<input type="text" name=phoneNumber class="layui-input"
						value="${payUnit.phoneNumber}" lay-verify="phone">
				</div>
			</div>
			<div class="layui-inline">
				<label class="layui-form-label">地址:</label>
				<div class="layui-input-inline">
					<input type="text" name="address" class="layui-input"
						value="${payUnit.address}" lay-verify="required">
				</div>
			</div>
		</div>

		<div class="layui-form-item"
			style="float: right; margin-right: 40%; margin-top: 30px">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit="" lay-filter="add">修改单位</button>
				<button class="layui-btn layui-btn-primary"
					onclick="return clearForm(this.form)">清空</button>
			</div>
		</div>
	</form>
</body>
</html>